<template>
	<view>
<!-- 按揭房信   -->
    <commonWin> </commonWin>
    <view class="top tac fw">
      <text>请完善</text>
      <text class="color">基本信息</text>
    </view>
		<view class="messageBar fz12">
			<view class="disb aic" @click="click(1)">
				<text>按揭房所在区域</text>
				<view class="select disp aic" style="font-weight: 700">
					<text class="color10">{{house.area?house.area:'请选择'}}</text>
					<image src="../../static/images/preat/right.png" mode=""></image>
				</view>
			</view>
		</view>

    <view class="messageBar fz12">
      <view class="disb aic" @click="click(4)">
        <text>房屋类型</text>
        <view class="select disp aic" style="font-weight: 700">
          <text class="color10">{{house.houseType?house.houseType:'请选择'}}</text>
          <image src="../../static/images/preat/right.png" mode=""></image>
        </view>
      </view>
    </view>

    <view class="messageBar fz12">
      <view class="disb aic" @click="click(3)">
        <text>房屋结构</text>
        <view class="select disp aic" style="font-weight: 700">
          <text class="color10">{{house.buildingStructure?house.buildingStructure:'请选择'}}</text>
          <image src="../../static/images/preat/right.png" mode=""></image>
        </view>
      </view>
    </view>

    <view class="messageBar fz12">
      <view class="disb aic" @click="click(7)">
        <text>装修情况</text>
        <view class="select disp aic" style="font-weight: 700">
          <text class="color10">{{house.decorateSituation?house.decorateSituation:'请选择'}}</text>
          <image src="../../static/images/preat/right.png" mode=""></image>
        </view>
      </view>
    </view>

		<view class="messageBar fz12">
			<view class="disb aic">
				<text>建筑面积</text>
				<view class="select disp aic" style="font-weight: 700">
					<u-input
              maxlength="10"
              type='digit'
					    placeholder="请输入"
						  inputAlign='right'
						  border='none'
					    v-model="house.areaOfStructure"
					></u-input>
          <text>㎡</text>
				</view>
			</view>
		</view>

		<u-picker :show="show" :immediateChange="true" :columns="list" keyName="category" @confirm="sexSelect" @cancel='show=false' closeOnClickOverlay  @close='show=false'></u-picker>
		<view class="upBtn tac colorf" @click="toSee">提交</view>
	</view>
</template>

<script>
	import {getHouseAsset,setHouseAsset,upDateHouseAsset} from "../../api/information.js"
  import commonWin from "./commonWin.vue";
	export default {
		name:"informtionList",
    components: {commonWin},
		props:{
      flag:{
        type:Boolean,
        default:()=>{return false}
      },
      pid:{
        type:String,
        default:()=>{return ''}
      },
      ui:{
        type:String,
        default:()=>{return "0"}
      },
			isThis:{
				type:Number,
				default:()=>{return ''}
			},
			listId:{
				type:String,
				default:()=>{return ''}
			},
		},
		data() {
			return {
				show:false,
				select:null,
				house:{
					userId:uni.getStorageSync('userInfo').id,
					area:'',
					landTypes:'',
					buildingStructure:'',
					houseType:'',
					areaOfStructure:'',
					oneOrTwo:'',
					mortgageTime:'',
					loanAmount:'',
          decorateSituation:''
				},
				list:[]
			};
		},
		onReady() {
			if(this.isThis==1){
				if(this.listId){
					this.getMessage()
				}
			}
		},
		methods:{
			// 获取填写保单资料
			getMessage(){
				getHouseAsset({id:this.listId,ui:this.ui}).then(res => {
					this.house = res.data
				})
			},
			//提交
			toSee(){
				if(this.listId){
					this.house.id = this.listId
          uni.$u.toast('资料提交中...')
					upDateHouseAsset(this.house).then(res => {
						if(res.code==0){
							uni.$u.toast('保存成功')
							setTimeout(()=>{
                uni.navigateBack()
							},500)
						}else{
							uni.$u.toast(res.msg)
						}
					})
				}else{
          uni.$u.toast('资料提交中...')
					setHouseAsset(this.house).then(res => {
						if(res.code==0){
              if (this.flag){
                uni.navigateTo({
                  url:`/pages/category/testLimit?id=&type=1&tableId=0`
                })
              }else {
                uni.navigateTo({
                  url:`/pages/category/testLimit?id=${this.pid}&type=0&tableId=`+res.data
                })
              }
						}else{
							uni.$u.toast(res.msg)
						}
					})
				}
			},
			//选择
			click(i){
				this.show = true
				this.select = i
				if(i==1){
					this.list = [['渝中','江北','渝北','南岸','九龙坡','沙坪坝','大渡口','巴南','北碚','璧山','永川','江津','綦江','南川','垫江','涪陵','长寿','合川','铜梁','大足','潼南','荣昌','武隆','彭水','酉阳','秀山','黔江','石柱','忠县','梁平','万州','开州','云阳','奉节','城口','巫溪','巫山']]
				}
				if(i==2){
					this.list = [['出让地','划拨地']]
				}
				if(i==3){
					this.list = [['钢筋混凝土结构','混合结构','其它']]
				}
				if(i==4){
					this.list = [['住宅','洋房','别墅','楼梯房','商住楼','商业','写字楼','其它']]
				}
				if(i==5){
					this.list = [['首套','二套']]
				}
				if(i==6){
					this.list = [['1个月','2个月','3个月','4个月','5个月','6个月','7个月','8个月','9个月','10个月','11个月','12个月']]
				}
        if(i==7){
          this.list = [['毛坯','清水','简装','精装','豪装']]
        }
			},
			//确认选择
			sexSelect(e){
				this.show = false
				if(this.select==1){
					this.house.area = e.value[0]
				}
				if(this.select==2){
					this.house.landTypes = e.value[0]
				}
				if(this.select==3){
					this.house.buildingStructure = e.value[0]
				}
				if(this.select==4){
					this.house.houseType = e.value[0]
				}
				if(this.select==5){
					this.house.oneOrTwo = e.value[0]
				}
				if(this.select==6){
					this.house.mortgageTime = e.value[0]
				}
        if(this.select==7){
          this.house.decorateSituation = e.value[0]
        }
			}
		}
	}
</script>

<style lang="scss">
.top{
	line-height: 80rpx;
	background-color: #eaf3ff;
}
.messageBar{
	min-height: 80rpx;
	line-height: 80rpx;
	padding: 0 30rpx;
	margin-bottom: 10rpx;
	background-color: #fff;
	.select{
		image{
			width: 20rpx;
			height: 30rpx;
			margin-left: 10rpx;
		}
	}
}
.upBtn{
	width: 80%;
	line-height: 80rpx;
	border-radius: 40rpx;
	background-color: #0055ff;
	margin: 40rpx auto 20rpx;
}
</style>